package com.shujia.wyh.day03;

/*
        逻辑运算符:
            &,|,^,!,&&,||

        特点：
            逻辑运算符一般用于连接boolean类型的表达式或者值

            表达式：用运算符将变量和常量连接起来的并且符合java语法规范的式子叫做表达式
            关系表达式：a==b
            算术表达式：a+b

       &:单与，又称之为逻辑与,有false则false
       |:单或，又称之为逻辑或,有true则true
       ^:异或，相同为false,不同为true
       !:非,将true变成false，将false变成true


 */
public class OptLogicDemo1 {
    public static void main(String[] args) {
        int a = 3;
        int b = 4;
        int c = 5;

        System.out.println("=====逻辑与运算=================================");
        //& 逻辑与运算
        System.out.println((a > b) & (a > c)); // false
        System.out.println((a > b) & (a < c)); // false
        System.out.println((a < b) & (a < c)); // true
        System.out.println((a < b) & (a > c)); // false

        System.out.println("=====逻辑或运算==================================");

        //| 逻辑或运算
        System.out.println((a > b) | (a > c)); // false
        System.out.println((a > b) | (a < c)); // true
        System.out.println((a < b) | (a < c)); // true
        System.out.println((a < b) | (a > c)); // true

        System.out.println("===逻辑异或运算==================================");

        //^逻辑异或运算
        System.out.println((a > b) ^ (a > c)); // false
        System.out.println((a > b) ^ (a < c)); // true
        System.out.println((a < b) ^ (a < c)); // false
        System.out.println((a < b) ^ (a > c)); // true

        System.out.println("=====逻辑非运算==================================");

        //! 逻辑非运算
        System.out.println(!(a>b));


    }
}





